home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / pack / ppcompress095.lha / ppstdio.c < prev   
C/C++ Source or Header  |  1992-11-14  |  639b  |  37 lines

  1. #include <clib/dos_protos.h>
  2. #include <clib/exec_protos.h>
  3. #include <exec/types.h>
  4. #include <stdio.h>
  5. #include "ppcompress.h"
  6.  
  7. #define OUTSIZE    80
  8.  
  9. char *GetMyStdIn(char *);
  10. BOOL PutMyStdOut(UBYTE *, int);
  11.  
  12. char *GetMyStdIn(char *tmp)
  13. {
  14. BPTR fh;
  15. UBYTE c;
  16.  
  17.     tmpnam(tmp);
  18.     if ( !(fh=Open(tmp, MODE_NEWFILE)) ) return(NULL);
  19.     while ( Read(Input(), &c, 1) ) Write(fh, &c, 1);
  20.     Close(fh);
  21.     return(tmp);
  22. }
  23.  
  24. BOOL PutMyStdOut(UBYTE *buffer, int len)
  25. {
  26. int remain;
  27.  
  28.     remain=len;
  29.     while( remain>0 ) {
  30.         if (USER_HIT_CTRL_C) return(FALSE);
  31.         Write(Output(), buffer, MIN(OUTSIZE, remain));
  32.         remain    -= OUTSIZE;
  33.         buffer    += OUTSIZE;
  34.     }
  35.     return(TRUE);
  36. }
  37.